package com.gobuy.system;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;
//import top.healthylife.watchdog.EnableWatchDog;

/**
 * @author Gaozexi on 2020/6/4 9:09
 * Step by Step  and Stand on,  You Are The Best Investment!
 */
//@EnableWatchDog
@EnableEurekaClient
@SpringBootApplication
public class GateWayApplication {
    public static void main(String[] args) {
        SpringApplication.run(GateWayApplication.class,args);
    }
    @Bean
    public KeyResolver ipKeyResolver(){
        return new KeyResolver() {
            @Override
            public Mono<String> resolve(ServerWebExchange exchange) {
                //获取当前客户端访问的ip,并进行限制
                ServerHttpRequest request = exchange.getRequest();
                return Mono.just(request.getRemoteAddress().getHostName());
            }
        };
    }

}
